package moe.net.controller.stress;


import jakarta.annotation.Resource;
import moe.net.req.stress.StressCaseModuleDelReq;
import moe.net.req.stress.StressCaseModuleSaveReq;
import moe.net.req.stress.StressCaseModuleUpdateReq;
import moe.net.service.stress.StressCaseModuleService;
import moe.net.util.JsonData;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * 测试用例模块
 */
@RestController
@RequestMapping("/api/v1/stress_case_module")
public class StressCaseModuleController {

    @Resource
    private StressCaseModuleService stressCaseModuleService;

    @GetMapping("/list")
    public JsonData list(@RequestParam("projectId") long projectId){
        return JsonData.buildSuccess(stressCaseModuleService.list(projectId));
    }

    @GetMapping("/find")
    public JsonData getById(@RequestParam("projectId") long projectId,@RequestParam("moduleId") long moduleId){
        return JsonData.buildSuccess(stressCaseModuleService.findById(projectId,moduleId));
    }

    @PostMapping("/save")
    public JsonData save(@RequestBody @Validated StressCaseModuleSaveReq moduleSaveReq){
        return JsonData.buildSuccess(stressCaseModuleService.save(moduleSaveReq));
    }

    @PostMapping("/update")
    public JsonData update(@RequestBody @Validated StressCaseModuleUpdateReq moduleUpdateReq){
        return JsonData.buildSuccess(stressCaseModuleService.update(moduleUpdateReq));
    }


    @PostMapping("/del")
    public JsonData delete(@RequestBody StressCaseModuleDelReq delReq){
        return JsonData.buildSuccess(stressCaseModuleService.delete(delReq.getProjectId(),delReq.getId()));
    }
}